package com.pharmacy.UserManage.dao;//package com.pharmacy.UserManage.dao;
//
//
//
//import com.pharmacy.UserManage.entity.SaleRecord;
//import org.apache.ibatis.annotations.*;
//
//import java.util.Date;
//import java.util.List;
//
//@Mapper
//public interface SaleRecordMapper {
//
//    // 获取所有销售记录
//    @Select("SELECT s.*, m.name as medicineName, u.username as operatorName " +
//            "FROM salerecord s " +
//            "JOIN medicine m ON s.medicineid = m.id " +
//            "JOIN user u ON s.operatorid = u.id " +
//            "ORDER BY s.saletime DESC")
//    List<SaleRecord> findAllSaleRecords();
//
//    // 条件查询销售记录
//    @Select("<script>" +
//            "SELECT s.*, m.name as medicineName, u.username as operatorName " +
//            "FROM salerecord s " +
//            "JOIN medicine m ON s.medicineid = m.id " +
//            "JOIN user u ON s.operatorid = u.id " +
//            "WHERE 1=1 " +
//            "<if test='startDate != null'>AND s.saletime &gt;= #{startDate}</if>" +
//            "<if test='endDate != null'>AND s.saletime &lt;= #{endDate}</if>" +
//            "<if test='medicineId != null'>AND s.medicineid = #{medicineId}</if>" +
//            "ORDER BY s.saletime DESC" +
//            "</script>")
//    List<SaleRecord> findSaleRecordsByCondition(@Param("startDate") Date startDate,
//                                                @Param("endDate") Date endDate,
//                                                @Param("medicineId") Integer medicineId);
//
//    // 添加销售记录
//    @Insert("INSERT INTO salerecord(medicineid, quantity, totalamount, operatorid) " +
//            "VALUES(#{medicineId}, #{quantity}, #{totalAmount}, #{operatorId})")
//    int addSaleRecord(SaleRecord saleRecord);
//
//    // 销售统计
//    @Select("SELECT m.name, SUM(s.quantity) as totalQuantity, SUM(s.totalamount) as totalAmount " +
//            "FROM salerecord s " +
//            "JOIN medicine m ON s.medicineid = m.id " +
//            "WHERE s.saletime BETWEEN #{startDate} AND #{endDate} " +
//            "GROUP BY s.medicineid " +
//            "ORDER BY totalAmount DESC")
//    List<SaleRecord> getSalesStatistics(@Param("startDate") Date startDate,
//                                        @Param("endDate") Date endDate);
//}
